using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.OleDb;
using QuanLyThuVien1.DTO;
namespace QuanLyThuVien1.DAO
{
   public class LoaiSach_DAO
    {
       public DataTable layDSTheLoai(string theLoai)
       {
           OleDbConnection connect = KETNOI.taoKetNoi();
           DataTable dStheoLoai = new DataTable();
           string connecstr = "select * from LOAISACH where theLoai = " + theLoai;
           OleDbDataAdapter olDDA = new OleDbDataAdapter(connecstr, connect);
           olDDA.Fill(dStheoLoai);
           connect.Close();
           return dStheoLoai;

       }
       public DataTable LayDSTheoMaLoai(string maLoai)
       {
           OleDbConnection connect = KETNOI.taoKetNoi();
           DataTable dSTheoMaLoai = new DataTable();
           string connecstr = "select * from LOAISACH where maLoaiSach = " + maLoai;
           OleDbDataAdapter olDDA = new OleDbDataAdapter(connecstr, connect);
           olDDA.Fill(dSTheoMaLoai);
           connect.Close();
           return dSTheoMaLoai;

       }
       public int LayMaLoai(string tenLoai)
       {
           DataTable d = new DataTable();
           OleDbConnection connect = KETNOI.taoKetNoi();
           string connecstr = "select maLoaiSach from LOAISACH where theLoai = '"+tenLoai+"'";
           OleDbCommand command = new OleDbCommand(connecstr, connect);
           OleDbDataAdapter adapter = new OleDbDataAdapter(command);
           adapter.Fill(d);
           connect.Close();
           return int.Parse(d.Rows[0][0].ToString());
       }

    }
}
